package com.urms.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.urms.entity.QueryUserCondition;
import com.urms.entity.User;
import com.urms.mapper.UserMapper;
import com.urms.service.UserSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserSerivceImpl implements UserSerivce {
    @Autowired
    private UserMapper userMapper;
    @Override
    public List<User> selectAll() {
        return userMapper.selectAll();
    }

    @Override
    public User selectByLoginNameAndPwd(User user) {
        return userMapper.selectByLoginNameAndPwd(user);
    }

    @Override
    public Integer insertUser(User user) {
        return userMapper.insertUser(user);
    }

    @Override
    public Integer deleteUserById(Integer userId) {
        return userMapper.deleteUserById(userId);
    }

    @Override
    public Integer updateUserStatusById(Integer id) {
        return userMapper.updateUserStatusById(id);
    }

    @Override
    public Integer updateHidden(Integer userId) {
        return userMapper.updateHidden(userId);
    }

    @Override
    public PageInfo<User> findUser(QueryUserCondition quc) {
        PageHelper.startPage(quc.getPageNum(),quc.getPageSize());
        List<User> list=userMapper.selectAll();
        PageInfo<User> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public PageInfo<User> selectUserByQuc(QueryUserCondition quc) {
        PageHelper.startPage(quc.getPageNum(),quc.getPageSize());
        List<User> list=userMapper.selectUsersByQuc(quc);
        PageInfo<User> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public User getPassword(Integer userId) {
        return userMapper.getPassword(userId);
    }

    @Override
    public PageInfo<User> userSelectByCondition(QueryUserCondition quc) {
        PageHelper.startPage(quc.getPageNum(),quc.getPageSize());
        List<User> users=userMapper.userSelectByCondition(quc);
        PageInfo<User> pageInfo=new PageInfo<>(users);
        return pageInfo;
    }

    @Override
    public Integer updateUserById(User user) {
        return userMapper.updateUserById(user);
    }

    @Override
    public Integer selectByuserName(String userLoginName) {
        return userMapper.selectByuserName(userLoginName
        );
    }

    @Override
    public Integer selectByPhone(String userPhone) {
        return userMapper.selectByPhone(userPhone);
    }

    @Override
    public Integer removeUserByIds(Integer[] ids) {
        return userMapper.removeUserByIds(ids);
    }
}
